#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

#define CHUNK_SIZE 100

void reverse(int c)
{
  char *p = malloc(CHUNK_SIZE);
  char *q;
  int pos = 1;
  int i;

  *p = c;

  while (c = getchar(), isalpha(c))
  {
    if (pos % CHUNK_SIZE == 0)
    {
      q = realloc(p, pos + CHUNK_SIZE);
      if (!q)
        exit(1);
      p = q;
    }
    p[pos++] = c;
  }

  ungetc(c, stdin);

  for (i = pos - 1; i >= 0; --i)
    putchar(p[i]);

  free(p);
}

int main(void)
{
  int c;

  while (c = getchar(), c != EOF)
  {
    if (isalpha(c))
      reverse(c);
    else
      putchar(c);
  }

  return 0;
}

